package jspx.example.interceptor.db;

import com.github.jspxnet.sioc.annotation.Bean;
import com.github.jspxnet.sober.Interceptor;
import com.github.jspxnet.sober.SoberSupport;
import com.github.jspxnet.utils.ObjectUtil;
import jspx.example.env.DemoIoc;

import java.util.Map;

/**
 * sql map 查询拦截器
 */
@Bean(bind = DemoInterceptor.class,namespace = DemoIoc.namespace)
public class DemoInterceptor implements Interceptor {
    @Override
    public void init() {
        System.out.println("-------DemoInterceptor init");
    }

    @Override
    public void before(SoberSupport soberSupport, Map<String, Object> valueMap) throws Exception
    {
        System.out.println("-------DemoInterceptor before =" + ObjectUtil.toString(valueMap));
    }

    @Override
    public Object after(SoberSupport soberSupport, Map<String, Object> valueMap, Object result) throws Exception {
        System.out.println("-------DemoInterceptor after =" + ObjectUtil.toString(result));
        return result;
    }

    @Override
    public void destroy() {
        System.out.println("-------DemoInterceptor destroy");
    }

}
